package com.elvende.web.client.presenter;

import com.elvende.web.client.event.ViewLifeEvent;
import com.elvende.web.client.service.GreetingServiceAsync;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Widget;

public class WelcomePresenter implements Presenter {

	public interface Display {
		HasClickHandlers getLogoCN();
//		HasClickHandlers getLogoEN();
		Widget asWidget();
	}
	
	 private final GreetingServiceAsync rpcService;
	  private final HandlerManager eventBus;
	  private final Display display;	
	
	  public WelcomePresenter(GreetingServiceAsync rpcService, HandlerManager eventBus, Display view) {
		    this.rpcService = rpcService;
		    this.eventBus = eventBus;
		    this.display = view;
		 }
	
	public void bind() {
		    display.getLogoCN().addClickHandler(new ClickHandler() {
		      public void onClick(ClickEvent event) {		    	
		        eventBus.fireEvent(new ViewLifeEvent());
		      }
		    });
	  }
	
	public void go(final HasWidgets container){
	    bind();
	    container.clear();
	    container.add(display.asWidget());
	    // fetchContactDetails();
	}

}
